(function($, window) {
	var staticRestuser = window.staticRestuser = {};
	var baseRequest = window.baseRequest;
	var appConfig = window.appConfig;
	var commonTool = window.commonTool;
	var dataManager = window.dataManager;
	var baseUrl = appConfig.oasisBaseUrl + '/oasis/stable/web/static/oasis-rest-user/restapp/users';
	
	//Add by dongyi
    //验证注册手机号是否存在
    var isPhoneNumExistUrl = baseUrl + '/isExistPhone/';
    staticRestuser.isPhoneNumExist = function(phoneNum,callback){
    	baseRequest.commonGet(isPhoneNumExistUrl+phoneNum, 5000, function (code, data) {
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (code === 0) {
                if (data.errcode) {
                    callback(1);
                } else {
                    callback(0, data.data);
                }
            }
        });
    }
    
    //验证注册邮箱是否存在
    var isEmailUserExistUrl = baseUrl + '/isExistEmail/';
    staticRestuser.isEmailExist = function(userEmail,callback){
    	 baseRequest.commonGet(isEmailUserExistUrl+userEmail, 5000, function (code, data) {
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (code === 0) {
                if (data.errcode) {
                    callback(1);
                } else {
                    callback(0, data.data);
                }
            }
        });
    }
    
    //验证注册用户名是否存在
    var isNameUserExistUrl = baseUrl + '/isExistName/';
    staticRestuser.isNameExist = function(userName,callback){
    	 baseRequest.commonGet(isNameUserExistUrl+userName, 5000, function (code, data) {
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (code === 0) {
                if (data.errcode) {
                    callback(1);
                } else {
                    callback(0, data.data);
                }
            }
        });
    }
    
    var phoneRegistUrl = baseUrl + '/addUser/phone';
    staticRestuser.phoneUserRegist = function (phoneUserInfo, callback) {
        baseRequest.commonPost(phoneRegistUrl, JSON.stringify(phoneUserInfo), 5000, function (code, data) {
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (data.code === 0) {
                callback(0);
            } else {
                callback(1, data.message);
            }
        });
    }
    var emailRegistUrl = baseUrl + '/addUser/email';
    staticRestuser.emailUserRegist = function (emailUserInfo, callback) {
        baseRequest.commonPost(emailRegistUrl, JSON.stringify(emailUserInfo), 5000, function (code, data) {
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (data.code === 0) {
                callback(0);
            } else {
                callback(1, data.message);
            }
        });
    }
    
    //手机找回密码
    var resetPasswordUrl = baseUrl + '/resetPwdWithCheck';
    staticRestuser.resetPwd = function (resetInfo, callback) {
        baseRequest.commonPost(resetPasswordUrl,JSON.stringify(resetInfo), 5000, function (code, data) {
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (data.code === 0) {
                callback(0);
            } else {
                callback(1, data.message);
            }
        });
    }
    
    //邮箱找回密码
    var resetPwdByEmailUrl = baseUrl + '/resetPwdWithEmail';
    staticRestuser.resetPwdByEmail = function (emailReset, callback) {
        baseRequest.commonPost(resetPwdByEmailUrl,JSON.stringify(emailReset), 5000, function (code, data) {
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (data.code === 0) {
                callback(0);
            } else {
                callback(1, data.message);
            }
        });
    }
	// end
})(mui, window);